<include file="Public:header" />
<script type="text/javascript" src="__PUBLIC__/style/js/TableFreeze.js"></script>
<style>
body{
	overflow-y: hidden;
}
</style>
<script>
$(function(){
	<if condition = "$_GET['content_id'] eq '' || $_GET['content_id'] eq 1">
		$("#table_div").height(window.innerHeight-$("#table_div").offset().top-$("#tfoot_div").height()-30);
		$(window).resize(function(){
			$("#table_div").height(window.innerHeight-$("#table_div").offset().top-$("#tfoot_div").height()-30);
			$("#oDivL_tab_Test3").height($("#table_div").height()).width($("#oTableLH_tab_Test3").width());
			$("#oDivH_tab_Test3").height($("#oTableLH_tab_Test3").height()).width($("#table_div").width());
		})
		$("#tab_Test3").FrozenTable(1,0,0);
		$("#oDivL_tab_Test3").height($("#table_div").height()).width($("#oTableLH_tab_Test3").width());
		$("#oDivH_tab_Test3").height($("#oTableLH_tab_Test3").height()).width($("#table_div").width());
	</if>
})

</script>
<script src="__PUBLIC__/js/chart/highcharts.js"></script>
<script src="__PUBLIC__/js/chart/modules/exporting.js"></script>
<div class="wrapper wrapper-content">
	<div class="row">
		<div class="col-lg-12">
			<div class="ibox float-e-margins">
				<include file="Public:analytics_left" />
				<input type="hidden" id="type_id" value="{$type_id}">
				<input type="hidden" id="content_id" value="{$content_id}">
				<div class="col-lg-10">
					<div class="ibox-content" style="padding-bottom:10px">
						<include file="Public:alert" />
						<div class="row">
							<div class="col-lg-3">
								<div class="pull-left" >
									<a href="javascript:void(0)" id="advance_search">高级筛选</a>
								</div>
							</div>
							<div class="col-lg-6">
								<if condition = "$_GET['content_id'] lt 4">
									<div style="margin:0 auto;width:300px;">
										<div class="col-lg-3">
											<a href="javascript:void(0);" class="select_time_a" rel="1" style="float:left;margin-right:15px;width:80px;font-weight: 500;">本月度</a>
										</div>
										<div class="col-lg-3">
											<a href="javascript:void(0);" class="select_time_a" rel="2" style="float:left;margin-right:15px;width:80px;font-weight: 500;">本季度</a>
										</div>
										<div class="col-lg-3">
											<a href="javascript:void(0);" class="select_time_a" rel="3" style="float:left;width:80px;font-weight: 500;">本年度</a>
										</div>
										<div class="col-lg-3">
											<a href="javascript:void(0);" class="select_time_a" rel="5" style="float:left;width:80px;font-weight: 500;">上一年</a>
										</div>
									</div>
								</if>
							</div>
						</div>
					</div>
					<div class="ibox-content full-height-scroll" id="right_height">
						<if condition = "$_GET['content_id'] eq 1">
							<div id="content_1" class="th_content">
								<div id="table_div" class="full-height-scroll" style="left:0px;top:0px;">
									<table class="table table-hover table-striped table_thead_fixed" id="tab_Test3" style="background:#fff;margin-bottom:0px;">
										<tr class="tabTh">
											<td style="width:25%">{:L('USER')}</td>
											<td style="width:25%">合同数</td>
											<td style="width:25%">合同总金额(元)</td>
											<td style="width:25%">已回款金额(元)</td>
											<td style="width:25%">剩余回款金额(元)</td>
										</tr>
										<volist name="reportList" id="vo">
										<tr>
											<td class=""> <a class="role_info" rel="{$vo.user.role_id}" href="javascript:void(0)">{$vo.user.user_name}</a></td>
											<td>
												 <a href="{:U('contract/index','field=owner_role_id&search='.$vo['user']['role_id'])}" target="_blank">
													 {$vo.contract_count}
												</a>
											</td> 
											<td> {$vo.contract_price}</td>
											<td> {$vo.receivingorder_price}</td>
											<td> {$vo.surplus_price}</td>
										</tr>
										</volist>
									</table>
								</div>
								<div id="tfoot_div" class="clearfix">
									<div class="clearfix" id="tfoot_page">
										<table class="table">						
											<tr style="background: #029BE2;color: #fff;font-size: 13px;">
												<td style="color:#fff;width:25%">{:L('TOTAL')}</td>
												<td style="color:#fff;width:25%">{$total_report.contract_count_total}</td>
												<td style="color:#fff;width:25%">{$total_report.contract_price_total}</td>
												<td style="color:#fff;width:25%">{$total_report.receivingorder_price_total}</td>
												<td style="color:#fff;width:25%">{$total_report.surplus_price_total}</td>
											</tr>
										</table>
									</div>
								</div>
							</div>
						</if>
						<if condition = "$_GET['content_id'] eq 2">
							<div id="content_2" class="th_content">
								<div id="an_chart">
									<div id="canvas_shoukuan" style="min-width:62%; height: 450px;"></div>
								</div>
							</div>
						</if>
						<if condition = "$_GET['content_id'] eq 3">
							<div id="content_3" class="hidden th_content">
								<div id="an_chart">
									<div id="canvas_moon" style="min-width:62%; height: 450px; margin: 0 auto"></div>
								</div>
							</div>
						</if>
						<div class="clearfix"></div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<div style="display: none;" id="dialog-role-info" title="{:L('DIALOG_USER_INFO')}">
	<div class="spiner-example">
		<div class="sk-spinner sk-spinner-three-bounce">
			<div class="sk-bounce1"></div>
			<div class="sk-bounce2"></div>
			<div class="sk-bounce3"></div>
		</div>
	</div>
</div>
<script type="text/javascript">
	//高级筛选
	$("#advance_search").click(function(){
		var mokuai_id = $('#type_id').val();
		var content_id = $('#content_id').val();
		var module_name = $('#module_name').val();
		var action_name = $('#action_name').val();
		var department = "{$_GET['department']}";
		var role = "{$_GET['role']}";
		$('#dialog-advance_search').dialog('open');
		$('#dialog-advance_search').load('{:U("finance/advance_search","mokuai_id=")}'+mokuai_id +'&content_id='+content_id+'&module_name='+module_name+'&action_name='+action_name+'&department='+department+'&role='+role); 
	});
	$("#dialog-advance_search").dialog({
		autoOpen: false,
		modal: true,
		width: 600,
		maxHeight: 450,
		position: ["center",100],
		buttons: {
			"确定": function () {
				var select_role = 0;
				var arys = new Array();
				var type_id = $('#type_id').val();
				var content_id = $('#content_id').val();
				$('#types_id').val(type_id);
				$('#contents_id').val(content_id);
				if(select_type == '' || select_type == 0){
					swal({
						title: "对比时间不能为空！",
						type: "error"
					});
					return false;
				}else{
					$('#advance_search_form').submit();
					return true;
				}
			},
			"取消": function () {
				$(this).dialog("close");
			}
		}
	});
	$(".select_time_a").click(function(){
		var select_time = $(this).attr('rel');
		var type_id = "{$_GET['type_id']}";
		var content_id = "{$_GET['content_id']}";  
		window.location.href="{:U('finance/analytics','&type_id=')}"+type_id+'&content_id='+content_id+'&select_type='+select_time+'&department=all&role=all';
	});
	<if condition="C('ismobile') eq 1">width=$('.container').width() * 0.9;<else/>width=800;</if>
	$("#dialog-role-info").dialog({
		autoOpen: false,
		modal: true,
		width: 600,
		maxHeight: 550,
		position: ["center",100]
	});
	
	$(".role_info").click(function(){
		$role_id = $(this).attr('rel');
		$('#dialog-role-info').dialog('open');
		$('#dialog-role-info').load('{:U("user/dialoginfo","id=")}'+$role_id);
	});
	
	$(function () {
		$('#canvas_moon').highcharts({
			chart: {
				type: 'column'
			},
			title: {
				text: '{:L('FINANCIAL INFORMATION MONTHLY STATISTICS')}'
			},
			xAxis: {
				categories: [
					'Jan',
					'Feb',
					'Mar',
					'Apr',
					'May',
					'Jun',
					'Jul',
					'Aug',
					'Sep',
					'Oct',
					'Nov',
					'Dec'
				]
			},
			yAxis: {
				min: 0,
				title: {
					text: '{:L('FINANCIAL INFORMATION MONTHLY STATISTICS')}'
				}
			},
			tooltip: {
				headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
				pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
					'<td style="padding:0"><b>{point.y:.1f} {:L('YUAN',array(''))}</b></td></tr>',
				footerFormat: '</table>',
				shared: true,
				useHTML: true
			},
			plotOptions: {
				column: {
					pointPadding: 0.2,
					borderWidth: 0
				}
			},
			series: [{
				name: '{:L('RECEIVABLES')}',
				data: {$moon_count['shoukuan']}
	
			}, {
				name: '{:L('THE ACTUAL RECEIVABLES')}',
				data: {$moon_count['shijishoukuan']}
	
			}]
		});
		$('#canvas_shoukuan').highcharts({
			chart: {
				type: 'column'
			},
			title: {
				text: '{:L('RECEIVINGORDER YOY')}'
			},
			xAxis: {
				categories: [
					'Jan',
					'Feb',
					'Mar',
					'Apr',
					'May',
					'Jun',
					'Jul',
					'Aug',
					'Sep',
					'Oct',
					'Nov',
					'Dec'
				]
			},
			yAxis: {
				min: 0,
				title: {
					text: '{:L('RECEIVINGORDER YOY')}'
				}
			},
			tooltip: {
				headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
				pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
					'<td style="padding:0"><b>{point.y:.1f} {:L('YUAN',array(''))}</b></td></tr>',
				footerFormat: '</table>',
				shared: true,
				useHTML: true
			},
			plotOptions: {
				column: {
					pointPadding: 0.2,
					borderWidth: 0
				}
			},
			series: [{
				name: '{:L('LAST YEAR')}',
				data: {$year_count['shoukuan_previousyear']}
	
			}, {
				name: '{:L('THIS YEAR')}',
				data: {$year_count['shoukuan_thisyear']}
	
			}]
		});
		
		
	});
	
	
	
	function changeRole(){
		department_id = $("#department option:selected").val();
		$.ajax({
			type:'get',
			url:'index.php?m=user&a=getrolebydepartment&department_id='+department_id,
			async:true,
			success:function(data){
				options = '<option value="all">{:L('ALL')}</option>';
				if(data.data != null){
					$.each(data.data, function(k, v){
						options += '<option value="'+v.role_id+'">'+v.role_name+"-"+v.user_name+'</option>';
					});
				}
				$("#role").html(options);
				<if condition="$_GET['role']">
				$("#role option[value='{$Think.get.role}']").prop("selected", true);
				</if>
			},
			dataType:'json'});
	}
	
	<if condition="$_GET['department'] and $_GET['department'] neq 'all'">
	$("#department option[value='{$Think.get.department}']").prop("selected", true); 
	changeRole();
	</if>
	<if condition="$_GET['department'] eq 'all'">
	$("#role option[value='{$Think.get.role}']").prop("selected", true);
	</if>
</script>
<include file="Public:footer" />